<?php
/**
 *Create by PhpStorm
 *User:Kendy
 *Date:2019/10/9/009
 *Time:16:19
 */
namespace app\admin\model;
use think\Model;
use think\Db;
use think\Request;
class LogOperates extends Model
{
    // 确定链接表名
    protected $name = 'log_operates';
    /**
     * 根据搜索条件获取所有的运营人员后台操作数据
     * @param $where  查询条件
     * @param $offset
     * @param $limit
     * @return mixed
     */
    public function getLogOperateList($where ,$offset, $limit)
    {
            $result = $this
            ->alias('lo')
            ->join('admin a','a.admin_id=lo.staff_id','LEFT')
            ->where($where)
            ->field('lo.*,a.admin_name')
            ->order('operate_id desc')
            ->limit($offset, $limit)
            ->select();
            if(count($result)>0)
            {
                foreach ($result as $key => $value) {
                     $result[$key]['operate_time'] = date('Y-m-d H:i:s',$value['operate_time']);
                }
                return $result;
            }
            return $result;
    }


    /**
     * 根据搜索条件获取所有的运营人员后台操作数量
     * @param $where  查询条件
     * @return mixed
     */
    public function  getLogOperateCount($where)
    {
        return $this->where($where)->count();
    }

    /**
     * [add 添加操作日志]
     * @Author   kendy
     * @DateTime 2019-11-27T15:05:13+0800
     * @param    [type]                   $param [description]
     */
    public function add($param){
        if (Request::instance()->isAjax()){ 
            $this->insert($param);   
        } 
         
    }


}